<#include "/layout/header.ftl" />
<#import "/include/ui.ftl" as blue />

<script>

$(function()
{
	
});

function save_click()
{
	$.simpleValid("#div_form", function(obj)
	{
		if (obj.id == "" && obj.password == "")
		{
			$.errorAlert("密码不能为空");
			return;
		}
		
		$.simpleAjax("/base/user/user_save", obj, function(o)
		{
			$.successAlert("保存成功", "save_success()", 2000);
		});
	});
}
function save_success()
{
	window.location = "${path}/base/user/user_list";
}

</script>

<div class="am-form am-form-horizontal am-cf am-margin" id="div_form">
<input type="hidden" name="id" value="${model.id!}"/>

	<fieldset>
		<legend><#if model.id??>修改<#else>添加</#if>账号</legend>
		<div class="am-u-md-6">
			<div class="am-form-group">
				<label class="am-u-md-2 am-form-label am-padding-left-0 am-padding-right-0">用户名</label>
				<div class="am-u-md-9 am-u-end">
					<input type="text" name="name" placeholder="输入用户名" class="am-form-field am-radius"  maxlength="20" value="${model.name!}" required/>
				</div>
			</div>
		</div>
		
		<div class="am-u-md-6">
			<div class="am-form-group">
				<label class="am-u-md-2 am-form-label am-padding-left-0 am-padding-right-0">手机</label>
				<div class="am-u-md-9 am-u-end">
					<input type="text" name="mobile" placeholder="输入手机号码" class="am-form-field am-radius js-pattern-mobile" maxlength="20" value="${model.mobile!}" required/>
				</div>
			</div>
		</div>
		
		<div class="am-u-md-6">
			<div class="am-form-group">
				<label class="am-u-md-2 am-form-label am-padding-left-0 am-padding-right-0">昵称</label>
				<div class="am-u-md-9 am-u-end">
					<input type="text" name="nickname" placeholder="输入用户昵称" class="am-form-field am-radius"  maxlength="10" value="${model.nickname!}" required/>
				</div>
			</div>
		</div>

		<div class="am-u-md-6">
			<div class="am-form-group">
				<label class="am-u-md-2 am-form-label am-padding-left-0 am-padding-right-0">状态</label>
				<div class="am-u-md-9 am-u-end">
					<select class="am-form-field am-radius" id="slt_state" name="state" data-am-selected="{'btnWidth': '120px'}" required>
						<@blue.select list=map.auth value=(model.auth.index)!"0" />
					</select>
				</div>
			</div>
		</div>
		
		<div class="am-u-md-6">
			<div class="am-form-group">
				<label class="am-u-md-2 am-form-label am-padding-left-0 am-padding-right-0">密码</label>
				<div class="am-u-md-9 am-u-end">
					<input type="password" id="txt_password" name="password" placeholder="输入密码，不修改留空" class="am-form-field am-radius"  maxlength="50" />
				</div>
			</div>
		</div>
		
		<div class="am-u-md-6">
			<div class="am-form-group">
				<label class="am-u-md-2 am-form-label am-padding-left-0 am-padding-right-0">确认密码</label>
				<div class="am-u-md-9 am-u-end">
					<input type="password" name="password2" placeholder="确认密码" class="am-form-field am-radius"
						data-equal-to="#txt_password" data-validation-message="2次密码不一致" maxlength="50" />
				</div>
			</div>
		</div>
		
		<div class="am-u-md-6">
			<div class="am-form-group">
				<label class="am-u-md-2 am-form-label am-padding-left-0 am-padding-right-0">邮箱</label>
				<div class="am-u-md-9 am-u-end">
					<input type="text" name="email" placeholder="输入邮箱" class="am-form-field am-radius js-pattern-email" maxlength="100" value="${model.email!}"/>
				</div>
			</div>
		</div>

		<div class="am-u-md-12 am-text-center div_btn">
			<a href="javascript:void(0)" onclick="save_click()" class="am-btn am-btn-primary am-radius">保存</a>
			<a href="javascript:void(0)" onclick="save_success()" class="am-btn am-btn-default am-radius am-margin-left">返回</a>
		</div>
	</fieldset>
</div>

<#include "/layout/footer.ftl" />